﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace GPExplorer {
    /// <summary>
    /// Displays A list of all the users libraries
    /// </summary>
    public partial class FrmLibraries : Form {
        /// <summary>
        /// Initializes a new instance of the <see cref="FrmLibraries"/> class.
        /// </summary>
        public FrmLibraries() {
            InitializeComponent();
        }

        /// <summary>
        /// Handles the Load event of the FrmLibraries control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void FrmLibraries_Load(object sender, EventArgs e) {
 
           ICollection<string> _libs = Database.GetLibrariesDistinct();
            if (_libs.Count == 0) {
                CmdOk.Enabled = false;
            }
            foreach (string _lib in _libs) {
                LstLibraries.Items.Add(_lib);
            }
        }

        /// <summary>
        /// Gets or sets the library.
        /// </summary>
        /// <value>
        /// The library.
        /// </value>
        public string Library { get; set; }

        /// <summary>
        /// Handles the Click event of the CmdOk control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void CmdOk_Click(object sender, EventArgs e){
            Library = LstLibraries.SelectedItem.ToString();
        }
    }
}
